package com.lmx.repoDomain.tmodel;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToOne;

/**
 * 服务项目消耗品对应表
 */
@Entity
@Table(name = "tnb_service_merch")
@JsonApiResource(type = "servicemerch")
public class ServiceMerch extends BaseEntity {
	private NurseMerch merch;

	private CustomerServiceItem item;

	private Integer merchNum;

	private String remark;// 备注

	@Column(name = "merch_num") 
	public Integer getMerchNum() {
		return merchNum;
	}

	public void setMerchNum(Integer merchNum) {
		this.merchNum = merchNum;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "merch_id", foreignKey = @ForeignKey(name = "null"))
	public NurseMerch getMerch() {
		return merch;
	}

	public void setMerch(NurseMerch merch) {
		this.merch = merch;
	}

	@JsonApiToOne
	// @JsonApiLookupIncludeAutomatically(overwrite = true)
	// @Fetch(FetchMode.JOIN)
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "item_id", foreignKey = @ForeignKey(name = "null"))
	public CustomerServiceItem getItem() {
		return item;
	}

	public void setItem(CustomerServiceItem item) {
		this.item = item;
	}

	@Column(name = "remark")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}
}